package whr.modules.assessment.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import whr.modules.assessment.entity.AssessmentEntity;
import whr.modules.assessment.service.AssessmentService;
import whr.common.utils.PageUtils;
import whr.common.utils.R;



/**
 * 
 *
 * @author liuli
 * @email 
 * @date 2025-04-08 12:52:05
 */
@RestController
@RequestMapping("assessment/assessment")
public class AssessmentController {
    @Autowired
    private AssessmentService assessmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("assessment:assessment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = assessmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{assetsId}")
    @RequiresPermissions("assessment:assessment:info")
    public R info(@PathVariable("assetsId") Long assetsId){
		AssessmentEntity assessment = assessmentService.getById(assetsId);

        return R.ok().put("assessment", assessment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("assessment:assessment:save")
    public R save(@RequestBody AssessmentEntity assessment){
		assessmentService.save(assessment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("assessment:assessment:update")
    public R update(@RequestBody AssessmentEntity assessment){
		assessmentService.updateById(assessment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("assessment:assessment:delete")
    public R delete(@RequestBody Long[] assetsIds){
		assessmentService.removeByIds(Arrays.asList(assetsIds));

        return R.ok();
    }
    /**
     * 不同年份 的季度绩效考核
     */
    @GetMapping("/{year}/{quarter}")
    public List<AssessmentEntity> getPerformancesByYearAndQuarter(@PathVariable int year, @PathVariable String quarter) {
        return assessmentService.getPerformancesByYearAndQuarter(year, quarter);
    }
    /**
     * 拿到绩效的年份
     */
    @GetMapping("/year")
    public List<Integer> getPerformancesByYearAndQuarter() {
        return assessmentService.getYear();
    }

}
